#include <iostream>
#include <vector>
using namespace std;

class my_stack
{
	public:
	int top()
	{
		return _v.back();
	}
	void push(int x)
	{
		_v.push_back(x);
	}
	void pop()
	{
		_v.pop_back();
	}
	private:
		vector<int> _v;
};

void memu()
{
	my_stack s;
	while(true)
	{
		cout<<"-----------------" << endl;
		cout<<"0.退出"<<endl;
		cout << "1.取出栈顶元素" << endl;
		cout << "2.入栈" << endl;
		cout << "3.出栈" << endl;
		cout<<"-----------------" << endl;
		int x;
		cin >> x;
		if(x == 0) break;
		else if(x == 1) cout << "栈顶元素为" << s.top() <<endl;
		else if(x == 2)
		{
			cout << "输入入栈元素:"<<endl;
			int val;
			cin >> val;
			s.push(val);
		}
		else if(x == 3)
		{
			s.pop();
			cout <<"出栈成功！" << endl;
		}
	}
}

int main()
{
	memu();
	return 0;
}